/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * LOS_TC.c
 *
 *  Created on: 2023年9月20日
 *      Author: 64435
 *      20230920重构，将LOS_TMTC.c和LOS_FlightRrocedure.c中有关遥控信息处理的内容迁移至此
 */

#include "LOS_TC.h"
#include <math.h>

extern FIL rfile_task;

uint8_t LOS_FP_TCEX(FLIGHTTASK_t* task)
{
    uint32_t FPLOCK = 0;    //飞行程序解锁标志位 0：解锁 1：锁定
    
    //暂存一些上注的参数值
    static uint32_t bhr = 0;             //FATFS读操作需要，表示读了多少

    /* 任务管理 */
    FLIGHTTASK_t* ptask;
    FLIGHTTASK_t* pnext; 

    /* 姿控 */
    uint8_t FW_NUM[10];
    float FW_RPM = 0;
    uint8_t CMDBUF[10];
    int8_t duty = 0;

    /* 高分相机 */
    uint8_t CAM_U8PAR[4];
    uint16_t CAM_U16PAR = 0;
    uint32_t CAM_U32PAR = 0;

    /* 文件系统 */
    uint8_t FATFS_Result = 0;
    uint8_t errcnt = 0;

    /* 存储板 */
    static uint32_t wpadd = 0;  //写指针
    static uint32_t rpadd = 0;  //读指针
    uint8_t stoarg = 0;  //操作参数
    uint8_t delsata = 0; //清硬盘操作
    uint8_t rststo = 0;  //存储板复位操作
    uint8_t swsata = 0;  //硬盘上下电操作
    uint8_t selbaud = 0; //波特率选择操作

    /* 数传 */
    uint16_t u16buf = 0;
    uint32_t u32buf = 0;
    uint8_t script[16];
    
    uint32_t u32twobuf[2];

    /* 小相机 */
    uint32_t cmosarg[3];

    /* FRAM */
    static float fbuf[9];

    switch(task->tasknum)
    { 
        /* 姿控-单轴对日模式 */
        case TCCMD_AOCS_ONEAXISSUN:
        MODE_AOCS.AM_TCFLAG = 0XFF;
        MODE_AOCS.starttime = LOS_Time_SecFromBoot;
        memcpy(&MODE_AOCS.durtime, &task->arg[0], 4);
        //MODE_AOCS.TCmode = SunSearch;
        LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
        break;

        /* 姿控-三轴对日模式 */
        case TCCMD_AOCS_THREEAIXSSUN:
        MODE_AOCS.AM_TCFLAG = 0XFF;
        MODE_AOCS.starttime = LOS_Time_SecFromBoot;
        memcpy(&MODE_AOCS.durtime, &task->arg[0], 4);
        //MODE_AOCS.TCmode = SunPoint;
        LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
        break;

        /* 姿控-速率阻尼模式 */
        case TCCMD_AOCS_DAMPMODE:
        MODE_AOCS.AM_TCFLAG = 0XFF;
        MODE_AOCS.starttime = LOS_Time_SecFromBoot;
        memcpy(&MODE_AOCS.durtime, &task->arg[0], 4);
        //MODE_AOCS.TCmode = Damping;
        LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
        break;

        /* 姿控-对地心凝视模式 */
        case TCCMD_AOCS_STAREOMODE:
        memcpy(&MODE_AOCS.durtime, &task->arg[0], 4);
        FW_NUM[0] = task->arg[4];
        switch(FW_NUM[0])
        {
            case 0x00:  //主相机
            //MODE_AOCS.TCmode = CamGeo;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            case 0x01:  //小相机
            //MODE_AOCS.TCmode = CMOSGeo;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            case 0x02:  //X螺旋天线
            //MODE_AOCS.TCmode = XHelicalGeo;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            case 0x03:  //X微带天线
            //MODE_AOCS.TCmode = XMicroGeo;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            default:  //指令错误，什么都不做
        }
        break;

        /* 姿控-指令模式 */
        case TCCMD_AOCS_CMDMODE:
        MODE_AOCS.AM_TCFLAG = 0XFF;
        MODE_AOCS.starttime = LOS_Time_SecFromBoot;
        memcpy(&MODE_AOCS.durtime, &task->arg[0], 4);
        memcpy(LOS_Targetq, &task->arg[4], 16); //四元数
        //MODE_AOCS.TCmode = Command;
        LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
        break;

        /* 姿控-对目标凝视模式 */
        case TCCMD_AOCS_TARGETMODE:
        memcpy(&MODE_AOCS.durtime, &task->arg[0], 4);
        FW_NUM[0] = task->arg[4];
        memcpy(LOS_Targetpos, &task->arg[5], 12); //经纬度及地心距
        switch(FW_NUM[0])
        {
            case 0x00:  //主相机
            //MODE_AOCS.TCmode = CamTarget;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            case 0x01:  //小相机
            //MODE_AOCS.TCmode = CMOSTarget;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            case 0x02:  //X螺旋天线
            //MODE_AOCS.TCmode = XHelicalTarget;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            case 0x03:  //X微带天线
            //MODE_AOCS.TCmode = XMicroTarget;
            LOS_FP_EnterNewModeSwitch(MODE_AOCS.TCmode);
            MODE_AOCS.AM_TCFLAG = 0XFF;
            MODE_AOCS.starttime = LOS_Time_SecFromBoot;
            break;

            default:  //指令错误，什么都不做
        }
        break;

        /* 飞轮卸载模式 */
        case TCCMD_AOCS_FWSLOWDOWN:

        break;

        /* 安全模式 */
        case TCCMD_AOCS_SAFEMODE:
        //MODE_AOCS.TCmode = Safe;
        memcpy(&MODE_AOCS.durtime, &task->arg[0], 4);
        MODE_AOCS.starttime = LOS_Time_SecFromBoot;
        MODE_AOCS.AM_TCFLAG = 0XFF;
        //LOS_FP_EnterNewModeSwitch(Safe);
        break;


        /* 姿控-安装矩阵上注 */
        case TCCMD_AOCS_MATUP:
        memcpy(FW_NUM, task->arg, 1);
        memcpy(fbuf, &task->arg[1], 36);
        if (isnan(fbuf[0]) || isnan(fbuf[1]) || isnan(fbuf[2]) || isnan(fbuf[3]) || isnan(fbuf[4]) || isnan(fbuf[5]) || isnan(fbuf[6]) || isnan(fbuf[7]) || isnan(fbuf[8]))
        {
            //不操作
        }
        else
        {
            switch(FW_NUM[0])
            {
                case nID_StarSensorY:
                LOS_FVAR_ModifyMATSSY(fbuf);
                break;

                case nID_StarSensorZ:
                LOS_FVAR_ModifyMATSSZ(fbuf);
                break;

                case nID_SunSensor:
                LOS_FVAR_ModifyMATSUNS(fbuf);
                break;

                case nID_YH50:
                LOS_FVAR_ModifyMATYH50(fbuf);
                break;

                case nID_MagMe:
                LOS_FVAR_ModifyMATMAGME(fbuf);
                break;

                default:
            }
        }
        break;

        /* 姿控-屏蔽飞轮输出 */
        case TCCMD_AOCS_BLOCKFWOUT:
        LOS_FW_PERMIT = 0X55;
        break;

        /* 姿控-屏蔽磁力矩器输出 */
        case TCCMD_AOCS_BLOCKMTOUT:
        LOS_MT_PERMIT = 0X55;
        break;

        /* 姿控-恢复飞轮输出 */
        case TCCMD_AOCS_REFWOUT:
        LOS_FW_PERMIT = 0XAA;
        break;

        /* 姿控-恢复磁力矩器输出 */
        case TCCMD_AOCS_REMTOUT:
        LOS_MT_PERMIT = 0XAA;
        break;

        /* 姿控-设置单个飞轮转速 */
        case TCCMD_AOCS_SNGFWRPM:
        memcpy(FW_NUM, task->arg, 5);
        memcpy(&FW_RPM, &FW_NUM[1], 4);
        LOS_FW_SetAngvel(FW_NUM[0]-nID_WheelX, FW_RPM);
        break;

        /* 姿控-设置单个飞轮电流 */
        case TCCMD_AOCS_SNGFWCUR:
        memcpy(FW_NUM, task->arg, 5);
        memcpy(&FW_RPM, &FW_NUM[1], 4);
        LOS_FW_SetCurrent(FW_NUM[0]-nID_WheelX, FW_RPM);
        break;

        /* 姿控-设置单个飞轮力矩 */
        case TCCMD_AOCS_SNGFWTOR:
        memcpy(FW_NUM, task->arg, 5);
        memcpy(&FW_RPM, &FW_NUM[1], 4);
        LOS_FW_SetTorque(FW_NUM[0]-nID_WheelX, FW_RPM);
        break;

        /* 姿控-飞轮遥测请求指令 */
        case TCCMD_AOCS_FWTMREQ:
        memcpy(FW_NUM, task->arg, 1);
        LOS_FW_GetState(FW_NUM[0]-nID_WheelX);
        break;

        /* 姿控-星敏复位 */
        case TCCMD_AOCS_STARRST:
        memcpy(FW_NUM, task->arg, 1);
        LOS_StarSensor_CMD(FW_NUM[0], StarCMD_Reset);
        break;

        /* 姿控-星敏自检 */
        case TCCMD_AOCS_STARCHK:
        memcpy(FW_NUM, task->arg, 1);
        LOS_StarSensor_CMD(FW_NUM[0], StarCMD_Check);
        break;

        /* 姿控-星敏进入待机模式 */
        case TCCMD_AOCS_STARSTB:
        memcpy(FW_NUM, task->arg, 1);
        LOS_StarSensor_CMD(FW_NUM[0], StarCMD_Standby);
        break;

        /* 姿控-星敏进入姿态测量模式 */
        case TCCMD_AOCS_STARATT:
        memcpy(FW_NUM, task->arg, 1);
        LOS_StarSensor_CMD(FW_NUM[0], StarCMD_Attitude);
        break;

        /* 姿控-星敏参数配置 */
        case TCCMD_AOCS_STARSET:
        CMDBUF[0]=0X3C;
        CMDBUF[1]=0X14;
        CMDBUF[2]=0X15;
        CMDBUF[6]=0X00;
        memcpy(FW_NUM, task->arg, 4);
        CMDBUF[3]=FW_NUM[1];
        CMDBUF[4]=FW_NUM[2];
        CMDBUF[5]=FW_NUM[3];
        LOS_StarSensor_CMD(FW_NUM[0], CMDBUF);
        break;

        /* 姿控-星敏请求参数简包 */
        case TCCMD_AOCS_STARSHO:
        memcpy(FW_NUM, task->arg, 1);
        LOS_StarSensor_CMD(FW_NUM[0], StarCMD_Short);
        break;

        /* 姿控-星敏请求参数详包 */
        case TCCMD_AOCS_STARLON:
        memcpy(FW_NUM, task->arg, 1);
        LOS_StarSensor_CMD(FW_NUM[0], StarCMD_Long);
        break;

        /* 姿控-星敏配置参数请求 */
        case TCCMD_AOCS_STARPAR:
        memcpy(FW_NUM, task->arg, 1);
        LOS_StarSensor_CMD(FW_NUM[0], StarCMD_PAR);
        break;

        /* 姿控-星敏星图请求指令 */
        case TCCMD_AOCS_STARIMG:
        memcpy(FW_NUM, task->arg, 7);
        LOS_StarSensor_IMG(FW_NUM[0],&FW_NUM[1]);
        break;

        /* 姿控-星敏时间设置指令 */
        case TCCMD_AOCS_STARTIM:
        memcpy(FW_NUM, task->arg, 7);
        LOS_StarSensor_SetTime(FW_NUM[0],&FW_NUM[1]);
        break;

        /* 姿控-太敏配置指令 */
        case TCCMD_AOCS_SUNSSET:
        memcpy(FW_NUM, task->arg, 2);
        LOS_SunSensor_Set(FW_NUM[0], FW_NUM[1]);
        break;

        /* 姿控-太敏请求姿态信息 */
        case TCCMD_AOCS_SUNSREQ:
        LOS_SunSensor_GetSta();
        break;

        /* 姿控-太敏请求图像信息 */
        case TCCMD_AOCS_SUNSIMG:
        LOS_SunSensor_GetImage();
        break;

        /* 姿控-光纤陀螺数据查询 */
        case TCCMD_AOCS_FOGREQ:
        LOS_YH50_SendCMD(0x0000);
        break;

        /* 姿控-光纤陀螺软件复位 */
        case TCCMD_AOCS_FOGRST:
        LOS_YH50_SendCMD(0xE55E);
        break;

        /* 姿控-设置磁力矩器占空比 */
        case TCCMD_AOCS_MTDUTY:
        memcpy(FW_NUM, task->arg, 2);
        memcpy(&duty, &FW_NUM[1], 1);
        LOS_MagTrq_TC(FW_NUM[0], duty);
        break;

        /* 姿控-磁力矩器占空比置0 */
        case TCCMD_AOCS_MTZERO:
        LOS_MagTrq_TC(nID_MAGTRQX1, 0);
        LOS_MagTrq_TC(nID_MAGTRQY1, 0);
        LOS_MagTrq_TC(nID_MAGTRQZ1, 0);
        LOS_MagTrq_TC(nID_MAGTRQX2, 0);
        LOS_MagTrq_TC(nID_MAGTRQY2, 0);
        LOS_MagTrq_TC(nID_MAGTRQZ2, 0);
        break;

        /* 姿控-磁力矩器极性设置 */
        case TCCMD_AOCS_SETPOL:
        memcpy(FW_NUM, task->arg, 2);
        LOS_MagTrq_SetPol(FW_NUM[0], FW_NUM[1]);
        break;

        /* 姿控-单机强制故障 */
        case TCCMD_AOCS_FORCEFAIL:
        memcpy(FW_NUM, task->arg, 1);
        LOS_AOCS_ForceFailNorm(FW_NUM[0], 0X55);
        break;

        /* 姿控-单机强制正常 */
        case TCCMD_AOCS_FORCENORM:
        memcpy(FW_NUM, task->arg, 1);
        LOS_AOCS_ForceFailNorm(FW_NUM[0], 0XAA);
        break;

        /* 姿控-星上自主诊断单机状态 */
        case TCCMD_AOCS_SELF:
        memcpy(FW_NUM, task->arg, 1);
        LOS_AOCS_ForceFailNorm(FW_NUM[0], 0XCC);
        break;

        /* 姿控-星敏安装四元数上注 */
        case TCCMD_AOCS_SSMQUP:
        memcpy(FW_NUM, task->arg, 1);
        memcpy(fbuf, &task->arg[1], 16);
        if (isnan(fbuf[0]) || isnan(fbuf[1]) || isnan(fbuf[2]) || isnan(fbuf[3]))
        {
            //不操作
        }
        else
        {
            switch(FW_NUM[0])
            {
                case nID_StarSensorY:
                LOS_FVAR_ModifyMQSSY(&(task->arg[1]));
                break;

                case nID_StarSensorZ:
                LOS_FVAR_ModifyMQSSZ(&(task->arg[1]));
                break;

                default:
            }
        }
        break;

        /* 姿控-最大磁矩上注 */
        case TCCMD_AOCS_MGTMAXUP:
        memcpy(fbuf, task->arg, 24);
        if (isnan(fbuf[0]) || isnan(fbuf[1]) || isnan(fbuf[2]) || isnan(fbuf[3]) || isnan(fbuf[4]) || isnan(fbuf[5]))
        {
            //不操作
        }
        else
        {
            LOS_FVAR_ModifyMGTMAX(fbuf);
        }
        break;

        /* 姿控-地磁场模型使能 */
        case TCCMD_AOCS_ENMAGMODEL:
        //aocs_g_input_struct.MagModelFlag = 0xAA;
        break;

        /* 姿控-地磁场模型禁能 */
        case TCCMD_AOCS_DISMAGMODEL:
        //aocs_g_input_struct.MagModelFlag = 0x55;
        break;

        /* 姿控-设置期望角速度 */
        case TCCMD_AOCS_SETTARAVEL:
        memcpy(fbuf, task->arg, 12);
//        aocs_g_input_struct.W_target[0] = fbuf[0];
//        aocs_g_input_struct.W_target[1] = fbuf[1];
//        aocs_g_input_struct.W_target[2] = fbuf[2];
        break;

        /* 姿控测试-光纤陀螺角速度上注 */
        case TCCMD_AOCST_YH50ARGUP:
        memcpy(&TEST_YH50.axis_velsel, task->arg, 1);
        if (TEST_YH50.axis_velsel == 1)
        {
            memcpy(&TEST_YH50.x_gyro_upt, &task->arg[1], 4);
        }
        else if (TEST_YH50.axis_velsel == 2)
        {
            memcpy(&TEST_YH50.y_gyro_upt, &task->arg[1], 4);
        }
        else if (TEST_YH50.axis_velsel == 3)
        {
            memcpy(&TEST_YH50.z_gyro_upt, &task->arg[1], 4);
        }
        break;

        /* 姿控测试-MEMS角速度上注 */
        case TCCMD_AOCST_MEMSARGUP:
        memcpy(&TEST_MEMS.axis_velsel, task->arg, 1);
        if (TEST_MEMS.axis_velsel == 1)
        {
            memcpy(&TEST_MEMS.x_gyro_upt, &task->arg[1], 4);
        }
        else if (TEST_MEMS.axis_velsel == 2)
        {
            memcpy(&TEST_MEMS.y_gyro_upt, &task->arg[1], 4);
        }
        else if (TEST_MEMS.axis_velsel == 3)
        {
            memcpy(&TEST_MEMS.z_gyro_upt, &task->arg[1], 4);
        }
        break;

        /* 姿控测试-磁强计磁感应强度上注 */
        case TCCMD_AOCST_MAGMEARGUP:
        memcpy(&TEST_MAGME.axis_sel, task->arg, 1);
        if (TEST_MAGME.axis_sel == 1)
        {
            memcpy(&TEST_MAGME.x_upt, &task->arg[1], 4);
        }
        else if (TEST_MAGME.axis_sel == 2)
        {
            memcpy(&TEST_MAGME.y_upt, &task->arg[1], 4);
        }
        else if (TEST_MAGME.axis_sel == 3)
        {
            memcpy(&TEST_MAGME.z_upt, &task->arg[1], 4);
        }
        break;

        /* 姿控测试-太敏太阳角上注 */
        case TCCMD_AOCST_SUNSARGUP:
        memcpy(&TEST_SUNS.angsel, task->arg, 1);
        if (TEST_SUNS.angsel == 1)
        {
            memcpy(&TEST_SUNS.alpha_upt, &task->arg[1], 4);
        }
        else if (TEST_SUNS.angsel == 2)
        {
            memcpy(&TEST_SUNS.beta_upt, &task->arg[1], 4);
        }
        break;

        /* 姿控测试-星敏Y四元数上注 */
        case TCCMD_AOCST_SSYARGUP:
        memcpy(&TEST_SSY.q_sel, task->arg, 1);
        switch(TEST_SSY.q_sel)
        {
            case 0:
            memcpy(&TEST_SSY.q_upt[0], &task->arg[1], 4);
            break;
            case 1:
            memcpy(&TEST_SSY.q_upt[1], &task->arg[1], 4);
            break;
            case 2:
            memcpy(&TEST_SSY.q_upt[2], &task->arg[1], 4);
            break;
            case 3:
            memcpy(&TEST_SSY.q_upt[3], &task->arg[1], 4);
            break;
            default:
            break;
        }
        break;

        /* 姿控测试-星敏Z四元数上注 */
        case TCCMD_AOCST_SSZARGUP:
        memcpy(&TEST_SSZ.q_sel, task->arg, 1);
        switch(TEST_SSZ.q_sel)
        {
            case 0:
            memcpy(&TEST_SSZ.q_upt[0], &task->arg[1], 4);
            break;
            case 1:
            memcpy(&TEST_SSZ.q_upt[1], &task->arg[1], 4);
            break;
            case 2:
            memcpy(&TEST_SSZ.q_upt[2], &task->arg[1], 4);
            break;
            case 3:
            memcpy(&TEST_SSZ.q_upt[3], &task->arg[1], 4);
            break;
            default:
            break;
        }
        break;

        /* 姿控测试-GNSS位置上注 */
        case TCCMD_AOCST_GNSSARGUP:
        memcpy(&TEST_GNSS.pos_sel, task->arg, 1);
        switch(TEST_GNSS.pos_sel)
        {
            case 1:
            memcpy(&TEST_GNSS.pos_upt[0], &task->arg[1], 4);
            break;
            case 2:
            memcpy(&TEST_GNSS.pos_upt[1], &task->arg[1], 4);
            break;
            case 3:
            memcpy(&TEST_GNSS.pos_upt[2], &task->arg[1], 4);
            break;
            default:
            break;
        }
        break;

        /* 姿控测试-飞轮转速上注 */
        case TCCMD_AOCST_FWARGUP:
        memcpy(FW_NUM, task->arg, 1);
        if (FW_NUM[0] == 0)
        {
            memcpy(&TEST_FW[0].rpm_sel, &task->arg[1], 1);
            memcpy(&TEST_FW[0].rpm_upt, &task->arg[2], 4);
        }
        else if (FW_NUM[0] == 1)
        {
            memcpy(&TEST_FW[1].rpm_sel, &task->arg[1], 1);
            memcpy(&TEST_FW[1].rpm_upt, &task->arg[2], 4);
        }
        else if (FW_NUM[0] == 2)
        {
            memcpy(&TEST_FW[2].rpm_sel, &task->arg[1], 1);
            memcpy(&TEST_FW[2].rpm_upt, &task->arg[2], 4);
        }
        else if (FW_NUM[0] == 3)
        {
            memcpy(&TEST_FW[3].rpm_sel, &task->arg[1], 1);
            memcpy(&TEST_FW[3].rpm_upt, &task->arg[2], 4);
        }
        break;

        /* 姿控测试-GNSS工作模式上注 */
        case TCCMD_AOCST_GNSSMODEGUP:
        memcpy(&TEST_GNSS.mode_sel, task->arg, 1);
        memcpy(&TEST_GNSS.mode_upt, &task->arg[1], 1);
        break;

        /* 姿控测试-星敏Y观测星个数上注 */
        case TCCMD_AOCST_SSYSTARNUM:
        memcpy(&TEST_SSY.star_sel, task->arg, 1);
        memcpy(&TEST_SSY.StarNum_upt, &task->arg[1], 1);
        break;

        /* 姿控测试-太敏超视场标记设置 */
        case TCCMD_AOCST_SUNOVS:
        memcpy(&TEST_SUNS.ossel, task->arg, 1);
        memcpy(&TEST_SUNS.OverSight_upt, &task->arg[1], 1);
        break;

        /* 姿控测试-光纤陀螺光功率信号上注 */
        case TCCMD_AOCST_YH50LUM:
        memcpy(&TEST_YH50.lumsel, task->arg, 1);
        memcpy(&TEST_YH50.lum_upt, &task->arg[1], 4);
        break;

        /* 姿控测试-光纤陀螺X轴、Y轴、Z轴温度信号上注 */
        case TCCMD_AOCST_YH50TEMP:
        memcpy(&TEST_YH50.axis_tempsel, task->arg, 1);
        if (TEST_YH50.axis_tempsel == 1)
        {
            memcpy(&TEST_YH50.x_temp_upt, &task->arg[1], 4);
        }
        else if (TEST_YH50.axis_tempsel == 2)
        {
            memcpy(&TEST_YH50.y_temp_upt, &task->arg[1], 4);
        }
        else if (TEST_YH50.axis_tempsel == 3)
        {
            memcpy(&TEST_YH50.z_temp_upt, &task->arg[1], 4);
        }
        break;

        /* 姿控测试-星敏Y角速度上注 */
        case TCCMD_AOCST_SSYVELUP:
        memcpy(&TEST_SSY.angvel_sel, task->arg, 1);
        switch(TEST_SSY.angvel_sel)
        {
            case 1:
            memcpy(&TEST_SSY.angvel_upt[0], &task->arg[1], 4);
            break;
            case 2:
            memcpy(&TEST_SSY.angvel_upt[1], &task->arg[1], 4);
            break;
            case 3:
            memcpy(&TEST_SSY.angvel_upt[2], &task->arg[1], 4);
            break;
            default:
            break;
        }
        break;

        /* 姿控测试-星敏Z角速度上注 */
        case TCCMD_AOCST_SSZVELUP:
        memcpy(&TEST_SSZ.angvel_sel, task->arg, 1);
        switch(TEST_SSZ.angvel_sel)
        {
            case 1:
            memcpy(&TEST_SSZ.angvel_upt[0], &task->arg[1], 4);
            break;
            case 2:
            memcpy(&TEST_SSZ.angvel_upt[1], &task->arg[1], 4);
            break;
            case 3:
            memcpy(&TEST_SSZ.angvel_upt[2], &task->arg[1], 4);
            break;
            default:
            break;
        }
        break;

        /* 姿控测试-星敏Z观测星个数上注 */
        case TCCMD_AOCST_SSZSTARNUM:
        memcpy(&TEST_SSZ.star_sel, task->arg, 1);
        memcpy(&TEST_SSZ.StarNum_upt, &task->arg[1], 1);
        break;

        /* 姿控测试-GNSS速度上注 */
        case TCCMD_AOCST_GNSSVELUP:
        memcpy(&TEST_GNSS.vel_sel, task->arg, 1);
        switch(TEST_GNSS.vel_sel)
        {
            case 1:
            memcpy(&TEST_GNSS.vel_upt[0], &task->arg[1], 4);
            break;
            case 2:
            memcpy(&TEST_GNSS.vel_upt[1], &task->arg[1], 4);
            break;
            case 3:
            memcpy(&TEST_GNSS.vel_upt[2], &task->arg[1], 4);
            break;
            default:
            break;
        }
        break;
        /* 姿控测试-GNSS六根数上注 */
        case TCCMD_AOCST_GNSSSIXUP:
        memcpy(&TEST_GNSS.six_sel, task->arg, 1);
        switch(TEST_GNSS.six_sel)
        {
            case 1:
            memcpy(&TEST_GNSS.six_upt[0], &task->arg[1], 4);
            break;
            case 2:
            memcpy(&TEST_GNSS.six_upt[1], &task->arg[1], 4);
            break;
            case 3:
            memcpy(&TEST_GNSS.six_upt[2], &task->arg[1], 4);
            break;
            case 4:
            memcpy(&TEST_GNSS.six_upt[3], &task->arg[1], 4);
            break;
            case 5:
            memcpy(&TEST_GNSS.six_upt[4], &task->arg[1], 4);
            break;
            case 6:
            memcpy(&TEST_GNSS.six_upt[5], &task->arg[1], 4);
            break;
            default:
            break;
        }
        break;

////////////////////////////////////////////////////////////////////////////////////////////////
        /* 平台-开始烧写 */
        case TCCMD_SAT_StartDownload:
        PERMIT_UPLOAD_SD2FLASH = 1;
        break;

        /* 平台-复位后运行在FLASH0 */
        case TCCMD_SAT_FLASH0:
        PERMIT_UPLOAD_JUMP=10;  
        break;

        /* 平台-复位后运行在FLASH1 */
        case TCCMD_SAT_FLASH1:
        PERMIT_UPLOAD_JUMP = 20;
        break;

        /* 平台-发送CAN广播帧 */
        case TCCMD_SAT_CANRadio:
        LOS_CAN_Radio();
        break;

        /* 平台-重启422/485 */
        case TCCMD_SAT_Reboot422:
        LOS_MAX14830_Shutdown();
        break;

        /* 平台-进入测试模式 */
        case TCCMD_SAT_TESTMODE:
        LOS_TESTM_FLAG = 1;
        memcpy(&LOS_TESTM_DUR, task->arg, 4);
        LOS_TESTM_ENT = LOS_Time_SecFromBoot;
        LOS_FW_SetTorque(FW_X, 0);
        LOS_FW_SetTorque(FW_Y, 0);
        LOS_FW_SetTorque(FW_Z, 0);
        LOS_FW_SetTorque(FW_S, 0);
        break;

        /* 平台-下传单机即时遥测包 */
        case TCCMD_SAT_TMNOW:
        FW_NUM[0] = task->arg[0];
        if(FW_NUM[0]<6)
        {
            memcpy(&LOS_TM_ID[FW_NUM[0]], &task->arg[1], 1); //单机编号
            memcpy(&LOS_TM_Type[FW_NUM[0]], &task->arg[2], 1); //包类别
            LOS_TM_PackNum[FW_NUM[0]] = 1;
        }
        break;

        /* 平台-请求多包即时遥测 */
        case TCCMD_SAT_MultiTMNOW:
        FW_NUM[0] = task->arg[0];
        if(FW_NUM[0]<6)
        {
            memcpy(&LOS_TM_ID[FW_NUM[0]], &task->arg[1], 1);
            memcpy(&LOS_TM_Type[FW_NUM[0]], &task->arg[2], 1);
            memcpy(&LOS_TM_PackNum[FW_NUM[0]], &task->arg[3], 2);
        }
        break;

        /* 平台-设置上注写入SD基址 */
        case TCCMD_SAT_SETUPBASEADDR:
        memcpy(&LOS_UP_BASEADDR, task->arg, 4);
        break;


        /* 平台-清空SD卡中的上注程序 */
        case TCCMD_SAT_DeleteUPFile:
        f_unlink("1:upd.bin");
        break;

        /* 平台-地面授时 */
        case TCCMD_SAT_GroundTime:
        memcpy(&LOS_Time_Sec, task->arg, 4);
        LOS_Time_MilSec = 0;
        break;

        /* 平台-设置待操作上注文件号 */
        case TCCMD_SAT_SetUPFileNum:
        memcpy(&LOS_UPLOAD_FileNum, task->arg, 1);
        break;

        /* 平台-设置上注文件大小 */
        case TCCMD_SAT_SetUPFileSize:
        memcpy(&LOS_UPLOAD_FileSize, task->arg, 4);
        break;

        /* 平台-启动星务从测控读取上注文件 */
        case TCCMD_SAT_StartReadUPFromTC:
        LOS_UPLOAD_TC2OBC = 1;
        break;

        /* 平台-终止星务从测控读取上注文件 */
        case TCCMD_SAT_StopReadUPFromTC:
        LOS_UPLOAD_TC2OBC = 5;
        break;

        /* 平台-清空延时遥控队列 */
        case TCCMD_SAT_ClearTCList:
        ptask = phead -> next; //从链表头后的第一项开始往后找
        do
        {
            pnext = ptask -> next; //先存一下当前节点的下一个节点
            if (ptask != phead) //避免把链表头给删了
            {
                if (ptask != task) //当前指令就是“平台-清空延时遥控队列”，要删除掉除该指令外的其他指令
                {
                    LOS_FP_DeleteNode(ptask);
                }
                ptask = pnext;
            }
        } while (ptask != phead);
        break;

        /* 平台-计算机复位 */
        case TCCMD_SAT_OBCRESET:
        LOS_WDT_DWDSYSRST();
        break;

        /* 平台-读取SD卡中上注程序的大小*/
        case TCCMD_SAT_GETUPSIZE:
        if ((LOS_UPLOAD_TC2OBC != 1) && (LOS_UPLOAD_TC2OBC != 2) && (LOS_UPLOAD_TC2OBC != 3))
        {
            do
            {
                FATFS_Result = f_open(&rfile_task, "1:upd.bin", FA_OPEN_ALWAYS | FA_READ);
                errcnt++;
            } while (FATFS_Result!=FR_OK && errcnt < 10);
            if (FATFS_Result == FR_OK)
            {
                LOS_UPFILE_SIZE = f_size(&rfile_task);    //获取.bin文件大小
                f_lseek(&rfile_task, LOS_UPFILE_SIZE - 4);
                f_read(&rfile_task, &CRC32_SD_SAVE, 4, &bhr);
            }
            else //找不到文件
            {
                LOS_UPFILE_SIZE = 0;
            }
            f_close(&rfile_task);
        }
        break;

        /* 平台-设置遥测频率 */
        case TCCMD_SAT_SETTMFREQ:
        memcpy(FW_NUM, task->arg, 1);
        if (FW_NUM[0]==0)
        {
            LOS_TM_FreCtrl = 10;
        }
        else 
        {
            LOS_TM_FreCtrl = FW_NUM[0]*20;
        }
        break;

        /* 平台-计算SD卡中上注程序的CRC32值 */
        case TCCMD_SAT_CALSDCRC32CAL:
        CRC32_SD_OFFSET = 0;
        LOS_HFT_STA = 2;
        CRC32_SD_OBCCAL = 0;
        LOS_UPLOAD_FileReceived = LOS_UPFILE_SIZE;
        break;

        /* 平台-数传开始下传即时遥测 */
        case TCCMD_SAT_DTSTARTTM:
        LOS_DT_TMPERMIT = 0xAA;
        break;

        /* 平台-数传停止下传即时遥测 */
        case TCCMD_SAT_DTSTOPTM:
        LOS_DT_TMPERMIT = 0x55;
        break;

        /* 平台-修改模式切换阈值 */
        case TCCMD_SAT_MODIFYMCTR:
        memcpy(&FW_RPM, &task->arg[1], 4);
        LOS_FVAR_ModifyMCTR(FW_RPM, task->arg[0]);
        break;

        /* 平台-使能飞行程序延时执行 */
        case TCCMD_SAT_DELAYEN:
        LOS_FVAR_ModifyDELAYEN(0XABED5CFA);
        break;

        /* 平台-禁能飞行程序延时执行 */
        case TCCMD_SAT_DELAYDIS:
        LOS_FVAR_ModifyDELAYEN(0XCB2017CB);
        break;

        /* 平台-设置飞行程序延时时间 */
        case TCCMD_SAT_SETDELAY:
        memcpy(&u32buf, task->arg, 4);
        LOS_FVAR_ModifyDELAYDUR(u32buf);
        break;

        /* 平台-设置当班机状态为A机 */
        case TCCMD_SAT_SETTOA:
        LOS_FVAR_ModifyOBC(0XAAAAAAAA);
        break;

        /* 平台-设置当班机状态为B机 */
        case TCCMD_SAT_SETTOB:
        LOS_FVAR_ModifyOBC(0XBBBBBBBB);
        break;

        /* 平台-太阳翼+X热刀加电序列 */
        case TCCMD_SAT_SAX1START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKSAX1_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKSAX1_CODE] = 0X55;
        }
        break;

        /* 平台-太阳翼-X热刀加电序列 */
        case TCCND_SAT_SAX2START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKSAX2_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKSAX2_CODE] = 0X55;
        }
        break;

        /* 平台-UHF1天线热刀加电序列 */
        case TCCMD_SAT_UHF1START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKUHF1_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKUHF1_CODE] = 0X55;
        }
        
        break;

        /* 平台-UHF2天线热刀加电序列 */
        case TCCMD_SAT_UHF2START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKUHF2_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKUHF2_CODE] = 0X55;
        }
        
        break;

        /* 平台-VHF1天线热刀加电序列 */
        case TCCMD_SAT_VHF1START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKVHF1_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKVHF1_CODE] = 0X55;
        }
        break;

        /* 平台-VHF2天线热刀加电序列 */
        case TCCMD_SAT_VHF2START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKVHF2_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKVHF2_CODE] = 0X55;
        }
        break;

        /* 平台-遮光罩热刀1加电序列 */
        case TCCMD_SAT_LEN1START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKLEN1_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKLEN1_CODE] = 0X55;
        }
        break;

        /* 平台-遮光罩热刀2加电序列 */
        case TCCMD_SAT_LEN2START:
        memcpy(&u32buf, task->arg, 4);
        if (u32buf == 0XABED5CFA)
        {
            LOS_TK_SEL[TKLEN2_CODE] = 0XAA;
        }
        else
        {
            LOS_TK_SEL[TKLEN2_CODE] = 0X55;
        }
        break;

        /* 平台-设置烧绳次数上限 */
        case TCCMD_SAT_SETTKMAXCNT:
        memcpy(&u32buf, task->arg, 4);
        LOS_FVAR_ModifyTKMAXCNT(u32buf);
        break;

        /* 平台-设置烧绳持续时间 */
        case TCCMD_SAT_SETTKDUR:
        memcpy(&u32buf, task->arg, 4);
        LOS_FVAR_ModifyTKDUR(u32buf);
        break;

        /* 平台-GPS自动上电使能 */
        case TCCMD_SAT_ENGPSAUTO:
        memcpy(&u32buf, task->arg, 4);
        LOS_FVAR_ModifyGPSAUTO(u32buf);
        break;

        /* 平台-磁强计校准 */
        case TCCMD_SAT_MAGMECOMP:
        memcpy(fbuf, task->arg, 12);
        LOS_FVAR_ModifyMAGCOMP(fbuf);
        break;

        /* 平台-上注轨道根数 */
        case TCCMD_SAT_UPORBELM:
        memcpy(LOS_ORB_OE, task->arg, 24);
        break;

        /* 平台-上注位置速度 */
        case TCCMD_SAT_UPPOSVEL:
        memcpy(LOS_ORB_RV, task->arg, 24);
        break;

        /* 平台-上注轨道参数使能 */
        case TCCMD_SAT_ENUPORB:
        LOS_ORB_UPFLAG = 0XAA;
        break;

        /* 平台-下传小相机照片 */
        case TCCMD_SAT_DOWNCMOSPIC:
        LOS_CMOS_PICNUM = task->arg[0];
        if (LOS_CMOS_PICNUM < 100)
        {
            LOS_CMOS_Invbuf = LOS_TM_InvTime;
            LOS_TM_InvTime = 1;
        }
        break;

        /* 平台-调整遥测间隔 */
        case TCCMD_SAT_SETTMINV:
        memcpy(&u16buf, task->arg, 2);
        LOS_TM_InvTime = u16buf;
        memcpy(&u16buf, &(task->arg[2]), 2);
        LOS_TM_AdjustInvDur = u16buf;
        break;

        /* 平台-基础遥测30s一次 */
        case TCCMD_SAT_SETTMINV30S:
        LOS_TM_InvTime = 28;
        memcpy(&u16buf, task->arg, 2);
        LOS_TM_AdjustInvDur = u16buf;
        break;

        /* 平台-基础遥测2s一次 */
        case TCCMD_SAT_SETTMINV2S:
        LOS_TM_InvTime = 0;
        memcpy(&u16buf, task->arg, 2);
        LOS_TM_AdjustInvDur = u16buf;
        break;

        /* 平台-查询SD卡中照片长度 */
        case TCCMD_SAT_GETSDPICSIZE:
        LOS_CMOS_NUMBUF = task->arg[0];
        STA_CMOS.piccnt = LOS_CMOS_GetSDPicNum(&STA_CMOS.pictotalsize);
        if (LOS_CMOS_NUMBUF<100)
        {
            memcpy(&CMOS_NOWSIZE, &cmos_sdmsg[(uint32_t)LOS_CMOS_NUMBUF*5 + 1], 4);
        }
        else
        {
            CMOS_NOWSIZE = 0xFFFFFFFF;
        }
        break;

        /* 平台-修改FRAM中的UTC时间 */
        case TCCMD_SAT_MODFRAMUTC:
        memcpy(&u32buf, task->arg, 4);
        LOS_FVAR_ModifyFRUTC(u32buf);
        break;

        /* 平台-将星上时间设置为FRAM中的值 */
        case TCCMD_SAT_SETUTCTOFRAM:
        LOS_Time_Sec = LOS_FVAR_GetUTCFromFRAM();
        break;

        /* 平台-天线热刀使能/禁能 */
        case TCCMD_SAT_ENFRTKANTEN:
        memcpy(&u32buf, task->arg, 4);
        LOS_FVAR_ModifyTKANTEN(u32buf);
        break;

        /* 平台-太阳翼热刀使能/禁能 */
        case TCCMD_SAT_ENFRTKSAEN:
        memcpy(&u32buf, task->arg, 4);
        LOS_FVAR_ModifyTKSAEN(u32buf);
        break;

        /* 平台-小相机拍照并直接下传 */
        case TCCMD_SAT_CMOSDIRECT:
        break;

        /* 平台-重新初始化延时遥测文件 */
        case TCCMD_SAT_REINITDTMF:
        
        break;

        /* 平台-擦除FRAM */
        case TCCMD_SAT_ERASEFRAM:
        LOS_W25Q64_ChipErase();
        break;

        /* 平台-停止向测控请求工参 */
        case TCCMD_SAT_STOPASKTMTC:
        TMTC_PERMITARG = 0X55;
        break;

        /* 平台-开始向测控请求工参 */
        case TCCMD_SAT_STARTASKTMTC:
        TMTC_PERMITARG = 0XAA;
        break;

        /* 平台-FRAM擦除扇区 */
        case TCCMD_SAT_ERASEFRAMSECTOR:
        memcpy(&u32buf, task->arg, 4);
        LOS_W25Q64_SectorErase(u32buf);
        break;

        /* 平台-FRAM擦除块 */
        case TCCMD_SAT_ERASEFRAMBLOCK:
        memcpy(&u32buf, task->arg, 4);
        LOS_W25Q64_BlockErase(u32buf);
        break;

        /* 平台-设置数传自动开启 */
        case TCCMD_SAT_DTAUTOSET:
        memcpy(u32twobuf, task->arg, 8);
        LOS_FVAR_ModifyDTAUTO(u32twobuf);
        break;

        /* 平台-启动星务从数传读取上注文件 */
        case TCCMD_SAT_StartReadUPFromDT:
        LOS_UPLOAD_DT2OBC = 1;
        break;

        /* 平台-终止星务从数传读取上注文件 */
        case TCCMD_SAT_StopReadUPFromDT:
        LOS_UPLOAD_DT2OBC = 5;
        break;

        /* 平台-数传看门狗功能使能 */
        case TCCMD_SAT_DTWDTEN:
        STA_DT.ENWDT = 0XAA;
        break;

        /* 平台-数传看门狗禁能 */
        case TCCMD_SAT_DTWDTDIS:
        STA_DT.ENWDT = 0X55;
        break;

//////////////////////////////////////////////////////////
        /* 电源-配电扩展板硬件复位 */
        case TCCMD_EPS_RESETPD:
        LOS_EPS_ResetPDH();
        break;

        /* 电源-热控扩展板硬件复位 */
        case TCCMD_EPS_RESETTC:
        LOS_EPS_ResetTCH();
        break;

        /* 电源-星敏Y开机 */
        case TCCMD_EPS_SSYON:
        LOS_SSY_PWROn();
        break;

        /* 电源-星敏Y关机 */
        case TCCMD_EPS_SSYOFF:
        LOS_SSY_PWROff();
        break;

        /* 电源-星敏Z开机 */
        case TCCMD_EPS_SSZON:
        LOS_SSZ_PWROn();
        break;

        /* 电源-星敏Z关机 */
        case TCCMD_EPS_SSZOFF:
        LOS_SSZ_PWROff();
        break;

        /* 电源-飞轮X开机 */
        case TCCMD_EPS_FWXON:
        LOS_FW_PWROn(FW_X);
        break;

        /* 电源-飞轮X关机 */
        case TCCMD_EPS_FWXOFF:
        LOS_FW_PWROff(FW_X);
        break;

        /* 电源-飞轮Y开机 */
        case TCCMD_EPS_FWYON:
        LOS_FW_PWROn(FW_Y);
        break;

        /* 电源-飞轮Y关机 */
        case TCCMD_EPS_FWYOFF:
        LOS_FW_PWROff(FW_Y);
        break;

        /* 电源-飞轮Z开机 */
        case TCCMD_EPS_FWZON:
        LOS_FW_PWROn(FW_Z);
        break;

        /* 电源-飞轮Z关机 */
        case TCCMD_EPS_FWZOFF:
        LOS_FW_PWROff(FW_Z);
        break;

        /* 电源-飞轮S开机 */
        case TCCMD_EPS_FWSON:
        LOS_FW_PWROn(FW_S);
        break;

        /* 电源-飞轮S关机 */
        case TCCMD_EPS_FWSOFF:
        LOS_FW_PWROff(FW_S);
        break;

        /* 电源-光纤陀螺开机 */
        case TCCMD_EPS_YH50ON:
        LOS_YH50_PWROn();
        break;

        /* 电源-光纤陀螺关机 */
        case TCCMD_EPS_YH50OFF:
        LOS_YH50_PWROff();
        break;

        /* 电源-太敏开机 */
        case TCCMD_EPS_SUNSON:
        LOS_SUNS_PWROn();
        break;

        /* 电源-太敏关机 */
        case TCCMD_EPS_SUNSOFF:
        LOS_SUNS_PWROff();
        break;

        /* 电源-GNSS开机 */
        case TCCMD_EPS_GNSSON:
        LOS_GNSS_PWROn();
        break;

        /* 电源-GNSS关机 */
        case TCCMD_EPS_GNSSOFF:
        LOS_GNSS_PWROff();
        break;

        /* 电源-磁强计开机 */
        case TCCMD_EPS_MAGMEON:
        LOS_MagMe_PWROn();
        break;

        /* 电源-磁强计关机 */
        case TCCMD_EPS_MAGMEOFF:
        LOS_MagMe_PWROff();
        break;

        /* 电源-数传基带开机 */
        case TCCMD_EPS_BASEBANDON:
        LOS_DTBB_PWROn();
        break;

        /* 电源-数传基带关机 */
        case TCCMD_EPS_BASEBANDOFF:
        LOS_DTBB_PWROff();
        break;

        /* 电源-数传通道上电 */
        case TCCMD_EPS_CHANNELON:
        LOS_DTCH_PWROn();
        break;

        /* 电源-数传通道下电 */
        case TCCMD_EPS_CHANNELOFF:
        LOS_DTCH_PWROff();
        break;

        /* 电源-MEMS开机 */                  
        case TCCMD_EPS_MEMSON:
        LOS_MEMS_PWROn();
        break;
        /* 电源-MEMS关机 */
        case TCCMD_EPS_MEMSOFF:
        LOS_MEMS_PWROff();
        break;

        /* 电源-高分相机开机 */
        case TCCMD_EPS_CAMON:
        LOS_CAM_PWROn();
        break;

        /* 电源-高分相机关机 */
        case TCCMD_EPS_CAMOFF:
        LOS_CAM_PWROff();
        break;

        /* 电源-导航增强开机 */
        case TCCMD_EPS_NAVIENON:
        LOS_NaviEnhance_PWROn();
        break;

        /* 电源-导航增强关机 */
        case TCCMD_EPS_NAVIENOFF:
        LOS_NaviEnhance_PWROff();
        break;

        /* 电源-遮光罩展开热刀1上电 */
        case TCCMD_EPS_HOOD1ON:
        LOS_EPS_Switch(18, SWITCH_ON);
        break;

        /* 电源-遮光罩展开热刀1下电 */
        case TCCMD_EPS_HOOD1OFF:
        LOS_EPS_Switch(18, SWITCH_OFF);
        break;

        /* 电源-时空表开机 */
        case TCCMD_EPS_STON:
        LOS_SpaceTime_PWROn();
        break;

        /* 电源-时空表关机 */
        case TCCMD_EPS_STOFF:
        LOS_SpaceTime_PWROff();
        break;

        /* 电源-CMOS相机开机 */
        case TCCMD_EPS_CMOSON:
        LOS_CMOS_PWROn();
        break;

        /* 电源-CMOS相机关机 */
        case TCCMD_EPS_CMOSOFF:
        LOS_CMOS_PWROff();
        break;

        /* 电源-光电传感器开机 */
        case TCCMD_EPS_FOTONAMURON:
        LOS_FotonAmur_PWROn();
        break;

        /* 电源-光电传感器关机 */
        case TCCMD_EPS_FOTONAMUROFF:
        LOS_FotonAmur_PWROff();
        break;

        /* 电源-太阳翼+X展开开关开 */
        case TCCMD_EPS_SAXPON:
        LOS_EPS_Switch(22, SWITCH_ON);
        break;

        /* 电源-太阳翼+X展开开关关 */
        case TCCMD_EPS_SAXPOFF:
        LOS_EPS_Switch(22, SWITCH_OFF);
        break;

        /* 电源-太阳翼-X展开开关开 */
        case TCCMD_EPS_SAXNON:
        LOS_EPS_Switch(23, SWITCH_ON);
        break;

        /* 电源-太阳翼-X展开开关关 */
        case TCCMD_EPS_SAXNOFF:
        LOS_EPS_Switch(23, SWITCH_OFF);
        break;

        /* 电源-UHF1展开开关开 */
        case TCCMD_EPS_UHF1ON:
        LOS_UHF1_PWROn();
        break;

        /* 电源-UHF1展开开关关 */
        case TCCMD_EPS_UHF1OFF:
        LOS_UHF1_PWROff();
        break;

        /* 电源-VHF1展开开关开 */
        case TCCMD_EPS_VHF1ON:
        LOS_VHF1_PWROn();
        break;

        /* 电源-VHF1展开开关关 */
        case TCCMD_EPS_VHF1OFF:
        LOS_VHF1_PWROff();
        break;

        /* 电源-UHF2展开开关开 */
        case TCCMD_EPS_UHF2ON:
        LOS_UHF2_PWROn();
        break;

        /* 电源-UHF2展开开关关 */
        case TCCMD_EPS_UHF2OFF:
        LOS_UHF2_PWROff();
        break;

        /* 电源-VHF2展开开关开 */
        case TCCMD_EPS_VHF2ON:
        LOS_VHF2_PWROn();
        break;

        /* 电源-VHF2展开开关关 */
        case TCCMD_EPS_VHF2OFF:
        LOS_VHF2_PWROff();
        break;
        
        /* 电源-存储板开机 */
        case TCCMD_EPS_STORAGEON:
        LOS_SATA_PWROn();
        break;

        /* 电源-存储板关机 */
        case TCCMD_EPS_STORAGEOFF:
        LOS_SATA_PWROff();
        break;

        /* 电源-设置加热带温度 */
        case TCCMD_EPS_SETHEATERTEMP:
        memcpy(FW_NUM, task->arg, 3);
        LOS_EPS_TCSetTemp(FW_NUM[0], FW_NUM[1], FW_NUM[2]);
        break;

        /* 电源-遮光罩展开热刀2上电 */
        case TCCMD_EPS_HOOD2ON:
        LOS_EPS_Switch(24, SWITCH_ON);
        break;

        /* 电源-遮光罩展开热刀2下电 */
        case TCCMD_EPS_HOOD2OFF:
        LOS_EPS_Switch(24, SWITCH_OFF);
        break;
////////////////////////////////////////////////////////////////////
        /* 时空表-遥测请求 */
        case TCCMD_ST_GetSta:
        LOS_SpaceTime_GetSta();
        break;

        /* 时空表-启动数传 */
        case TCCMD_ST_StartDT:
        LOS_SpaceTime_StartDT();
        break;

        /* 时空表-开始轮询 */
        case TCCMD_ST_StartPoll:
        ST_PollFlag = 1;
        break;

        /* 时空表-停止轮询 */
        case TCCMD_ST_StopPoll:
        ST_PollFlag = 0;
        break;

        /* 高分相机-开始拍照 */
        case TCCMD_CAM_SNAP:
        LOS_CIOMPCam_Snap();
        break;

        /* 高分相机-成像模式设置 */
        case TCCMD_CAM_SETMODE:
        memcpy(CAM_U8PAR, task->arg, 4);
        LOS_CIOMPCam_SetMode(CAM_U8PAR[0], CAM_U8PAR[1], CAM_U8PAR[2], CAM_U8PAR[3]);
        break;

        /* 高分-停止拍照 */
        case TCCMD_CAM_STOP:
        LOS_CIOMPCam_Stop();
        break;

        /* 高分-GPS秒时间校时 */
        case TCCMD_CAM_GPSSECTIMING:
        LOS_CIOMPCam_SetTime(LOS_Time_Sec);
        break;

        /* 高分-GPS秒脉冲主份 */
        case TCCMD_CAM_PPSMAIN:
        LOS_CIOMPCam_PPSSelect(0x11);
        break;

        /* 高分-GPS秒脉冲备份 */
        case TCCMD_CAM_PPSSTANDBY:
        LOS_CIOMPCam_PPSSelect(0x22);
        break;

        /* 高分-GPS秒脉冲自身 */
        case TCCMD_CAM_PPSSELF:
        LOS_CIOMPCam_PPSSelect(0x33);
        break;

        /* 高分-增益设置 */
        case TCCMD_CAM_SETGAIN:
        memcpy(CAM_U8PAR, task->arg, 1);
        LOS_CIOMPCam_SetGain(CAM_U8PAR[0]);
        break;

        /* 高分-帧周期设置 */
        case TCCMD_CAM_SETFRAMECYCLE:
        memcpy(&CAM_U32PAR, task->arg, 4);
        LOS_CIOMPCam_SetFramePeriod(CAM_U32PAR);
        break;

        /* 高分-曝光时间设置 */
        case TCCMD_CAM_SETEXPOTIME:
        memcpy(&CAM_U32PAR, task->arg, 4);
        LOS_CIOMPCam_SetExposureTime(CAM_U32PAR);
        break;

        /* 高分-CMOS输出方向不翻转 */
        case TCCMD_CAM_CMOSNOFLIP:
        LOS_CIOMPCam_SetCMOSDirection(0x00);
        break;

        /* 高分-CMOS输出方向水平翻转 */
        case TTCMD_CAM_CMOSFLIPHOR:
        LOS_CIOMPCam_SetCMOSDirection(0x01);
        break;

        /* 高分-CMOS输出方向垂直翻转 */
        case TCCMD_CAM_CMOSFLIPVER:
        LOS_CIOMPCam_SetCMOSDirection(0x02);
        break;

        /* 高分-CMOS输出方向水平+垂直翻转 */
        case TCCMD_CAM_CMOSFLIPHAV:
        LOS_CIOMPCam_SetCMOSDirection(0x03);
        break;

        /* 高分-状态查询 */
        case TCCMD_CAM_GETSTATE:
        LOS_CIOMPCam_GetState();
        break;

        /* 高分-视频模式起始行设置 */
        case TCCMD_CAM_VSTARTLINE:
        memcpy(&CAM_U16PAR, task->arg, 2);
        LOS_CIOMPCam_SetVFirstLine(CAM_U16PAR);
        break;

        /* 高分-推扫模式起始行设置 */
        case TCCMD_CAM_SSTARTLINE:
        memcpy(&CAM_U16PAR, task->arg, 2);
        LOS_CIOMPCam_SetSFirstLine(CAM_U16PAR);
        break;

        /* 高分-位选指令 */
        case TCCMD_CAM_SELECTBIT:
        memcpy(CAM_U8PAR, task->arg, 1);
        LOS_CIOMPCam_SelectBit(CAM_U8PAR[0]);
        break;

        /* 高分-FPN校正使能 */
        case TCCMD_CAM_FPNEN:
        LOS_CIOMPCam_FPNCorrection(0x55);
        break;

        /* 高分-FPN校正禁用 */
        case TCCMD_CAM_FPNDIS:
        LOS_CIOMPCam_FPNCorrection(0xAA);
        break;

        /* 高分-SDPC校正使能 */
        case TCCMD_CAM_SDPCEN:
        LOS_CIOMPCam_SDPCCorrection(0x55);
        break;

        /* 高分-SDPC校正禁用 */
        case TCCMD_CAM_SDPCDIS:
        LOS_CIOMPCam_SDPCCorrection(0xAA);
        break;

        /* 高分-加载出厂配置 */
        case TCCMD_CAM_LOADFACSET:
        LOS_CIOMPCam_Config(0x44,0x00);
        break;

        /* 高分-加载用户配置 */
        case TCCMD_CAM_LOADUSRSET:
        memcpy(CAM_U8PAR, task->arg, 1);
        LOS_CIOMPCam_Config(0x66, CAM_U8PAR[0]);
        break;

        /* 高分-存储用户配置 */
        case TCCMD_CAM_SAVEUSRSET:
        memcpy(CAM_U8PAR, task->arg, 1);
        LOS_CIOMPCam_Config(0x88, CAM_U8PAR[0]);
        break;

        /* 高分-推扫模式级数设置 */
        case TCCMD_CAM_SETPROG:
        memcpy(CAM_U8PAR, task->arg, 1);
        LOS_CIOMPCam_ProgressionSet(CAM_U8PAR[0]);
        break;

//////////////////////////////////////////////////////////////
        /* 小相机-拍照 */
        case TCCMD_CMOS_SNAP:
        LOS_CMOS_Snap();
        break;

        /* 小相机-发送最近一张照片 */
        case TCCMD_CMOS_SENDRECENT:
        LOS_CMOS_SendRecentPhoto();
        break;

        /* 小相机-发送最近一张照片编号和长度 */
        case TCCMD_CMOS_RECENTMSG:
        LOS_CMOS_SendRecentPhotoMsg();
        break;

        /* 小相机-发送本机工参 */
        case TCCMD_CMOS_SENDCAMARG:
        LOS_CMOS_STA();
        break;

        /* 小相机-重新格式化FLASH */
        case TCCMD_CMOS_FORMATFLASH:
        LOS_CMOS_FormatFlash();
        break;

        /* 小相机-发送全部照片状态 */
        case TCCMD_CMOS_ALLPHOTOSTA:
        LOS_CMOS_AllPhotoMsg();
        break;

        /* 小相机-设置当前拍照参数为默认参数 */
        case TCCMD_CMOS_DEFAULT:
        LOS_CMOS_DefaultArg();
        break;

        /* 小相机-发送当前FLASH拍照参数 */
        case TCCMD_CMOS_GETNOWARG:
        LOS_CMOS_CheckArg();
        break;

        /* 小相机-设置拍照参数 */
        case TCCMD_CMOS_CONFIG:
        memcpy(FW_NUM, task->arg, 6);
        LOS_CMOS_SetArg(FW_NUM[0], FW_NUM[1], FW_NUM[2], FW_NUM[3], FW_NUM[4], FW_NUM[5]);
        break;

        /* 小相机-照片读取 */
        case TCCMD_CMOS_READPHOTO:
        memcpy(cmosarg, task->arg, 12);
        LOS_CMOS_ReadPhoto(cmosarg[0], cmosarg[1], cmosarg[2]);
        break;

        /* 小相机-请求指定照片长度 */
        case TCCMD_CMOS_PHOTOLENGTH:
        memcpy(&FW_NUM[0], task->arg, 1);
        LOS_CMOS_PhotoLength(FW_NUM[0]);
        break;

        /* 小相机-请求指定照片参数 */
        case TCCMD_CMOS_PHOTOARG:
        memcpy(&FW_NUM[0], task->arg, 1);
        LOS_CMOS_PhotoArg(FW_NUM[0]);
        break;

        /* 小相机-指定照片存入SD卡 */
        case TCCMD_CMOS_SAVE2SD:
        STA_CMOS.picid_TC = task->arg[0];
        STA_CMOS.readsta = 1;
        break;

        /* 小相机-删除SD卡照片文件 */
        case TCCMD_CMOS_DELETEFILE:
        f_unlink("1:cms.bin");
        break;

        /* 小相机-重新初始化SD卡照片文件 */
        case TCCMD_CMOS_REINITFILE:
        LOS_CMOS_FileReInit();
        break;

/////////////////////////////////////////////////////////////

        /* 导航增强-基本状态遥测轮询 */
        case TCCMD_NVE_POLL:
        LOS_NaviEnhance_CMD(NaviEnhance_CMD_Status);
        break;

        case TCCMD_NVE_UP72:
        LOS_NaviEnhance_UP();
        break;

/////////////////////////////////////////////////////////////
        /* 存储板-设置指针地址 */
        case TCCMD_STO_SETADDR:
        memcpy(&wpadd, task->arg, 4);
        memcpy(&rpadd, &(task->arg[4]), 4);
        LOS_SATA_Control(wpadd, rpadd, 0, 0, 0, 0, 0);
        break;

        /* 存储板-数据发送接收控制 */
        case TCCMD_STO_TRANSET:
        memcpy(&stoarg, task->arg, 1);
        LOS_SATA_Control(wpadd, rpadd, stoarg, 0, 0, 0, 0);
        break;

        /* 存储板-清硬盘数据 */
        case TCCMD_STO_CLEARSATA:
        LOS_SATA_Control(wpadd, rpadd, 0, 0x55, 0, 0, 0);
        break;

        /* 存储板-复位指令 */
        case TCCMD_STO_RESET:
        LOS_SATA_Control(wpadd, rpadd, 0, 0, 0x55, 0, 0);
        break;

        /* 存储板-硬盘上电 */
        case TCCMD_STO_SATAON:
        LOS_SATA_Control(wpadd, rpadd, 0, 0, 0, 0x55, 0);
        break;

        /* 存储板-硬盘下电 */
        case TCCMD_STO_SATAOFF:
        LOS_SATA_Control(wpadd, rpadd, 0, 0, 0, 0xAA, 0);
        break;

        /* 存储板-设置数传串口波特率 */
        case TCCMD_STO_SETBAUD:
        memcpy(&stoarg, task->arg, 1);
        LOS_SATA_Control(wpadd, rpadd, 0, 0, 0, 0, stoarg);
        break;

        /* 存储板-遥控指令 */
        case TCCMD_STO_TELECMD:
        memcpy(&wpadd, task->arg, 4);
        memcpy(&rpadd, &(task->arg[4]), 4);
        stoarg = task->arg[8];
        delsata = task->arg[9];
        rststo = task->arg[10];
        swsata = task->arg[11];
        selbaud = task->arg[12];
        LOS_SATA_Control(wpadd, rpadd, stoarg, delsata, rststo, swsata, selbaud);
        break;

        /* 存储板-遥测请求 */
        case TCCMD_STO_GETSTATE:
        LOS_SATA_GetState();
        break;
//////////////////////////////////////////////////
        /* 数传-发送零字节指令 */
        case TCCMD_DT_CMD0BYTE:
        LOS_DT_CMD0BYTE(task->arg[0]);
        break;

        /* 数传-发送一字节指令 */
        case TCCMD_DT_CMD1BYTE:
        LOS_DT_CMD1BYTE(task->arg[0], task->arg[1]);
        break;

        /* 数传-发送四字节指令 */
        case TCCMD_DT_CMD4BYTE:
        LOS_DT_CMD4BYTE(task->arg[0], &task->arg[1]);
        break;

        /* 数传-发送八字节指令 */
        case TCCMD_DT_CMD8BYTE:
        LOS_DT_CMD8BYTE(task->arg[0], &task->arg[1]);
        break;

        /* 数传-发送十六字节指令 */
        case TCCMD_DT_CMD16BYTE:
        LOS_DT_CMD16BYTE(task->arg[0], &task->arg[1]);
        break;

////////////////////////////////////////////////
        /* 测控-本机复位 */
        case TCCMD_TMTC_RESET:
        LOS_TMTC_Reset();
        break;

        /* 测控-读取本机工程参数 */
        case TCCMD_TMTC_GETSTATUS:
        LOS_TMTC_GetStatus();
        break;

        /* 测控-设置待操作文件 */
        case TCCMD_TMTC_SETFILE:
        FW_NUM[0] = task->arg[0];
        LOS_TMTC_SetFile(FW_NUM[0]);
        break;

        /* 测控-删除文件 */
        case TCCMD_TMTC_DELETEFILE:
        FW_NUM[0] = task->arg[0];
        LOS_TMTC_DeleteFile(FW_NUM[0]);
        break;

        /* 测控-设置目标nid */
        case TCCMD_TMTC_SETNID:
        FW_NUM[0] = task->arg[0];
        LOS_TMTC_SetTargetnID(FW_NUM[0]);
        break;

        /* 测控-读取文件数据块 */
        case TCCMD_TMTC_READBLOCK:
        memcpy(&cmosarg[0], &(task->arg[0]), 4);
        memcpy(&cmosarg[1], &(task->arg[4]), 4);
        LOS_TMTC_ReadBlock(cmosarg[0], cmosarg[1]);
        break;

        /* 测控-FTP开始传输 */
        case TCCMD_TMTC_FTPSTART:
        LOS_TMTC_FTPStart();
        break;

        /* 测控-FTP停止传输 */
        case TCCMD_TMTC_FTPSTOP:
        LOS_TMTC_FTPStop();
        break;

        /* 测控-设置seed */
        case TCCMD_TMTC_SETSEED:
        memcpy(script, &(task->arg[0]), 16);
        LOS_TMTC_SetSeed(script);
        break;

        /* 测控-设置连续传输包数 */
        case TCCMD_TMTC_SETPACKCNT:
        memcpy(&u16buf, &(task->arg[0]), 2);
        LOS_TMTC_SetPackCNT(u16buf);
        break;

        /* 测控-设置FTP发送包间隔 */
        case TCCMD_TMTC_SETFTPINV:
        FW_NUM[0] = task->arg[0];
        LOS_TMTC_SetFTPInv(FW_NUM[0]);
        break;

        /* 测控-通过无线信道下传本机工程参数 */
        case TCCMD_TMTC_ARGDOWNVIARF:
        LOS_TMTC_ArgDownViaRF();
        break;

        /* 测控-30秒遥测下发开 */
        case TCCMD_TMTC_TM30SON:
        LOS_TMTC_TM30SON();
        break;

        /* 测控-30秒遥测下发关 */
        case TCCMD_TMTC_TM30SOFF:
        LOS_TMTC_TM30SOFF();
        break;

        /* 测控-通过无线信道下传文件数据块 */
        case TCCMD_TMTC_FILEDOWNVIARF:
        memcpy(&cmosarg[0], &(task->arg[0]), 4);
        memcpy(&cmosarg[1], &(task->arg[4]), 4);
        LOS_TMTC_FileDownViaRF(cmosarg[0], cmosarg[1]);
        break;

/////////////////////////////////////////////////////////////
        /* 光电传感器 */
        /* 光电-发送各种参数 */
        case TCCMD_AMUR_SENDARG:
        LOS_FotonAmur_SendCommand(AmurCMD_TEMP);
        LOS_FotonAmur_SendCommand(AmurCMD_Q1);
        LOS_FotonAmur_SendCommand(AmurCMD_Q2);
        LOS_FotonAmur_SendCommand(AmurCMD_Q3);
        LOS_FotonAmur_SendCommand(AmurCMD_Q4);
        break;

        /* 光电-授时 */
        case TCCMD_AMUR_TIME:
        LOS_FotonAmur_SetTime();
        break;

        /* 光电-执行下电序列 */
        case TCCMD_AMUR_PWRDOWN:
        STA_FotonAmur.CMD = 2;
        STA_FotonAmur.PWRDOWN_Time = LOS_Time_SecFromBoot;
        break;

        /* 光电-显示时间 */
        case TCCMD_AMUR_SHOWTIME:
        LOS_FotonAmur_ShowTime();
        break;

        /* 光电-温度反馈 */
        case TCCMD_AMUR_GETTEMP:
        LOS_FotonAmur_GetTemp();
        break;

        /* 光电-测试指令 */
        case TCCMD_AMUR_TEST:
        LOS_FotonAmur_TC(task->arg);
        break;

        default:
        return 0;
    }
    LOS_TC_EX++;  //遥控指令执行计数+1
    LOS_TC_LASTCMD = task->tasknum;  //最近一条执行指令
}



/** @fn void LOS_TMTC_TCUnpack(uint8_t* pack, uint16_t len)
*   @brief 遥控解包函数
*   @param[in] pack CAN总线上收到的遥控指令包
*   @param[in] len  包长度
*   @note 根据遥控协议进行解包
*/
void LOS_TMTC_TCUnpack(uint8_t* pack, uint16_t len)
{
    uint16_t length = len;
    uint16_t cnt = 0;
    int16_t arglen = 0;


    while(length != 0)
    {
        arglen = LOS_TMTC_TCReadCMD(&pack[cnt]);
        cnt += (9 + (uint16_t)arglen);
        length -= (9 + (uint16_t)arglen);
        if (length < 9)
        {
            length = 0;
        }
    }
}

/** @fn int16_t LOS_TMTC_TCReadCMD(uint8_t* pack)
*   @brief 遥控读指令函数
*   @param[in] pack 前四字节为指令码的数据包
*   @return 指令参数长度
*   @note 读取指令码和执行时间，将指令加入遥控指令链表，并存入参数
*/
int16_t LOS_TMTC_TCReadCMD(uint8_t* pack)
{
    uint32_t TCCMD = 0;
    uint32_t TCTIME = 0;
    int16_t arglen = 0;
    FLIGHTTASK_t* taskbuf;
    uint16_t cnt = 0;
    uint8_t csum = 0; //校验和

    memcpy(&TCCMD, pack, 4);
    memcpy(&TCTIME, &pack[4], 4);
    arglen = LOS_TMTC_CalArgLen(TCCMD);
    if (arglen != -1)  //检索到该指令
    {
        /* 检验校验和 */
        for (cnt = 0; cnt < 8 + arglen; cnt++)
        {
            csum += pack[cnt]; 
        }

        if (csum == pack[8+arglen])   //校验和正确
        {
            taskbuf = LOS_FP_CreateTable(TCCMD,TCTIME);
            if (arglen != 0)
            {
                taskbuf -> arg = (uint8_t*)pvPortMalloc(arglen);
                memcpy(taskbuf->arg, &pack[8], arglen);
            }
            else
            {
                taskbuf -> arg = NULL;
            }
            LOS_TC_READ++;   //读取遥控指令计数+1
            LOS_TC_LASTCMDTIME = LOS_Time_SecFromBoot; //最近一条收到指令的时间
        }
        else //校验和错误
        {
            arglen = 0;
        }
    }
    else
    {
        arglen = 0;
    }

    return arglen;     //返回参数长度，便于计算下一条指令的位置
}

/** @fn int16_t LOS_TMTC_CalArgLen(uint32_t TCCMD)
*   @brief 遥控指令参数长度
*   @param[in] TCCMD 遥控指令码
*   @return 该指令对应的参数长度，若查找不到指令返回-1
*   @note 根据输入的指令码，返回该指令对应的参数长度，单位字节
*/
int16_t LOS_TMTC_CalArgLen(uint32_t TCCMD)
{
    switch (TCCMD)
    {
        /* 姿控分系统指令 */
        case TCCMD_AOCS_ONEAXISSUN:
        return 4;

        case TCCMD_AOCS_THREEAIXSSUN:
        return 4;

        case TCCMD_AOCS_DAMPMODE:
        return 4;

        case TCCMD_AOCS_STAREOMODE:
        return 5;

        case TCCMD_AOCS_CMDMODE:
        return 20;

        case TCCMD_AOCS_TARGETMODE:
        return 17;

        case TCCMD_AOCS_FWSLOWDOWN:
        return 4;

        case TCCMD_AOCS_SAFEMODE:
        return 4;

        case TCCMD_AOCS_MATUP:
        return 4*9 + 1;

        case TCCMD_AOCS_BLOCKFWOUT:
        return 1;

        case TCCMD_AOCS_BLOCKMTOUT:
        return 1;

        case TCCMD_AOCS_REFWOUT:
        return 1;

        case TCCMD_AOCS_REMTOUT:
        return 1;

        case TCCMD_AOCS_SNGFWRPM:
        return 1+4;

        case TCCMD_AOCS_SNGFWCUR:
        return 1+4;

        case TCCMD_AOCS_SNGFWTOR:
        return 1+4;

        case TCCMD_AOCS_FWTMREQ:
        return 1;

        case TCCMD_AOCS_STARRST:
        return 1;

        case TCCMD_AOCS_STARCHK:
        return 1;

        case TCCMD_AOCS_STARSTB:
        return 1;

        case TCCMD_AOCS_STARATT:
        return 1;

        case TCCMD_AOCS_STARSET:
        return 1*4;

        case TCCMD_AOCS_STARSHO:
        return 1;

        case TCCMD_AOCS_STARLON:
        return 1;

        case TCCMD_AOCS_STARPAR:
        return 1;

        case TCCMD_AOCS_STARIMG:
        return 7;

        case TCCMD_AOCS_STARTIM:
        return 7;

        case TCCMD_AOCS_SUNSSET:
        return 2*8;

        case TCCMD_AOCS_SUNSREQ:
        return 0;

        case TCCMD_AOCS_SUNSIMG:
        return 0;

        case TCCMD_AOCS_FOGREQ:
        return 0;

        case TCCMD_AOCS_FOGRST:
        return 0;

        case TCCMD_AOCS_MTDUTY:
        return 1*2;

        case TCCMD_AOCS_MTZERO:
        return 0;

        case TCCMD_AOCS_SETPOL:
        return 1*2;

        case TCCMD_AOCS_FORCEFAIL:
        return 1;

        case TCCMD_AOCS_FORCENORM:
        return 1;

        case TCCMD_AOCS_SELF:
        return 1;

        case TCCMD_AOCS_SSMQUP:
        return 17;

        case TCCMD_AOCS_MGTMAXUP:
        return 24;

        case TCCMD_AOCS_ENMAGMODEL:
        return 0;

        case TCCMD_AOCS_DISMAGMODEL:
        return 0;

        case TCCMD_AOCS_SETTARAVEL:
        return 12;

        /* 平台指令 */
        case TCCMD_SAT_StartDownload:
        return 0;

        case TCCMD_SAT_FLASH0:
        return 0;

        case TCCMD_SAT_FLASH1:
        return 0;

        case TCCMD_SAT_CANRadio:
        return 0;

        case TCCMD_SAT_Reboot422:
        return 0;

        case TCCMD_SAT_TESTMODE:
        return 4;

        case TCCMD_SAT_TMNOW:
        return 3;

        case TCCMD_SAT_MultiTMNOW:
        return 5;

        case TCCMD_SAT_SETUPBASEADDR:
        return 4;

        case TCCMD_SAT_DeleteUPFile:
        return 0;

        case TCCMD_SAT_GroundTime:
        return 4;

        case TCCMD_SAT_SetUPFileNum:
        return 1;

        case TCCMD_SAT_SetUPFileSize:
        return 4;

        case TCCMD_SAT_StartReadUPFromTC:
        return 0;

        case TCCMD_SAT_StopReadUPFromTC:
        return 0;

        case TCCMD_SAT_ClearTCList:
        return 0;

        case TCCMD_SAT_OBCRESET:
        return 0;

        case TCCMD_SAT_GETUPSIZE:
        return 0;

        case TCCMD_SAT_SETTMFREQ:
        return 1;

        case TCCMD_SAT_CALSDCRC32CAL:
        return 0;


        case TCCMD_SAT_MODIFYMCTR:
        return 5;

        case TCCMD_SAT_DTSTARTTM:
        return 0;

        case TCCMD_SAT_DTSTOPTM:
        return 0;


        case TCCMD_SAT_UPORBELM:
        return 24;

        case TCCMD_SAT_UPPOSVEL:
        return 24;

        case TCCMD_SAT_ENUPORB:
        return 0;

        case TCCMD_SAT_DOWNCMOSPIC:
        return 1;

        case TCCMD_SAT_SETTMINV:
        return 4;

        case TCCMD_SAT_SETTMINV30S:
        return 2;

        case TCCMD_SAT_SETTMINV2S:
        return 2;

        case TCCMD_SAT_GETSDPICSIZE:
        return 1;

        case TCCMD_SAT_MODFRAMUTC:
        return 4;

        case TCCMD_SAT_SETUTCTOFRAM:
        return 0;

        case TCCMD_SAT_ENFRTKANTEN:
        return 4;

        case TCCMD_SAT_ENFRTKSAEN:
        return 4;

        case TCCMD_SAT_CMOSDIRECT:
        return 0;

        case TCCMD_SAT_REINITDTMF:
        return 0;

        case TCCMD_SAT_ERASEFRAM:
        return 0;

        case TCCMD_SAT_STOPASKTMTC:
        return 0;

        case TCCMD_SAT_STARTASKTMTC:
        return 0;

        case TCCMD_SAT_ERASEFRAMSECTOR:
        return 4;

        case TCCMD_SAT_ERASEFRAMBLOCK:
        return 4;

        case TCCMD_SAT_DELAYEN:
        return 0;

        case TCCMD_SAT_DELAYDIS:
        return 0;

        case TCCMD_SAT_SETDELAY:
        return 4;

        case TCCMD_SAT_SETTOA:
        return 0;

        case TCCMD_SAT_SETTOB:
        return 0;

        case TCCMD_SAT_SAX1START:
        return 4;

        case TCCND_SAT_SAX2START:
        return 4;

        case TCCMD_SAT_UHF1START:
        return 4;

        case TCCMD_SAT_UHF2START:
        return 4;

        case TCCMD_SAT_VHF1START:
        return 4;

        case TCCMD_SAT_VHF2START:
        return 4;

        case TCCMD_SAT_LEN1START:
        return 4;

        case TCCMD_SAT_LEN2START:
        return 4;

        case TCCMD_SAT_SETTKMAXCNT:
        return 4;

        case TCCMD_SAT_SETTKDUR:
        return 4;

        case TCCMD_SAT_ENGPSAUTO:
        return 4;

        case TCCMD_SAT_MAGMECOMP:
        return 12;

        case TCCMD_SAT_DTAUTOSET:
        return 8;

        case TCCMD_SAT_StartReadUPFromDT:
        return 0;

        case TCCMD_SAT_StopReadUPFromDT:
        return 0;

        case TCCMD_SAT_DTWDTEN:
        return 0;

        case TCCMD_SAT_DTWDTDIS:
        return 0;

        /* 供配电分系统指令 */
        case TCCMD_EPS_RESETPD:
        return 0;

        case TCCMD_EPS_RESETTC:
        return 0;

        case TCCMD_EPS_SSYON:
        return 0;

        case TCCMD_EPS_SSYOFF:
        return 0;

        case TCCMD_EPS_SSZON:
        return 0;

        case TCCMD_EPS_SSZOFF:
        return 0;

        case TCCMD_EPS_FWXON:
        return 0;

        case TCCMD_EPS_FWXOFF:
        return 0;
        
        case TCCMD_EPS_FWYON:
        return 0;

        case TCCMD_EPS_FWYOFF:
        return 0;

        case TCCMD_EPS_FWZON:
        return 0;

        case TCCMD_EPS_FWZOFF:
        return 0;

        case TCCMD_EPS_FWSON:
        return 0;

        case TCCMD_EPS_FWSOFF:
        return 0;

        case TCCMD_EPS_YH50ON:
        return 0;

        case TCCMD_EPS_YH50OFF:
        return 0;

        case TCCMD_EPS_SUNSON:
        return 0;

        case TCCMD_EPS_SUNSOFF:
        return 0;

        case TCCMD_EPS_GNSSON:
        return 0;

        case TCCMD_EPS_GNSSOFF:
        return 0;

        case TCCMD_EPS_MAGMEON:
        return 0;

        case TCCMD_EPS_MAGMEOFF:
        return 0;

        case TCCMD_EPS_BASEBANDON:
        return 0;
       
        case TCCMD_EPS_BASEBANDOFF:
        return 0;

        case TCCMD_EPS_CHANNELON:
        return 0;
        
        case TCCMD_EPS_CHANNELOFF:
        return 0;

        case TCCMD_EPS_MEMSON:
        return 0;

        case TCCMD_EPS_MEMSOFF:
        return 0;

        case TCCMD_EPS_CAMON:
        return 0;

        case TCCMD_EPS_CAMOFF:
        return 0;

        case TCCMD_EPS_NAVIENON:
        return 0;

        case TCCMD_EPS_NAVIENOFF:
        return 0;

        case TCCMD_EPS_HOOD1ON:
        return 0;

        case TCCMD_EPS_HOOD1OFF:
        return 0;

        case TCCMD_EPS_STON:
        return 0;

        case TCCMD_EPS_STOFF:
        return 0;

        case TCCMD_EPS_CMOSON:
        return 0;

        case TCCMD_EPS_CMOSOFF:
        return 0;

        case TCCMD_EPS_FOTONAMURON:
        return 0;

        case TCCMD_EPS_FOTONAMUROFF:
        return 0;

        case TCCMD_EPS_SAXPON:
        return 0;

        case TCCMD_EPS_SAXPOFF:
        return 0;

        case TCCMD_EPS_SAXNON:
        return 0;

        case TCCMD_EPS_SAXNOFF:
        return 0;

        case TCCMD_EPS_UHF1ON:
        return 0;

        case TCCMD_EPS_UHF1OFF:
        return 0;

        case TCCMD_EPS_VHF1ON:
        return 0;

        case TCCMD_EPS_VHF1OFF:
        return 0;

        case TCCMD_EPS_UHF2ON:
        return 0;

        case TCCMD_EPS_UHF2OFF:
        return 0;

        case TCCMD_EPS_VHF2ON:
        return 0;

        case TCCMD_EPS_VHF2OFF:
        return 0;

        case TCCMD_EPS_STORAGEON:
        return 0;

        case TCCMD_EPS_STORAGEOFF:
        return 0;

        case TCCMD_EPS_SETHEATERTEMP:
        return 3;

        case TCCMD_EPS_HOOD2ON:
        return 0;

        case TCCMD_EPS_HOOD2OFF:
        return 0;


        /* 时空表 */
        case TCCMD_ST_GetSta:
        return 0;

        case TCCMD_ST_StartDT:
        return 0;

        case TCCMD_ST_StartPoll:
        return 0;

        case TCCMD_ST_StopPoll:
        return 0;

        /* 高分相机 */
        case TCCMD_CAM_SNAP:
        return 0;

        case TCCMD_CAM_SETMODE:
        return 4;

        case TCCMD_CAM_STOP:
        return 0;

        case TCCMD_CAM_GPSSECTIMING:
        return 0;

        case TCCMD_CAM_PPSMAIN:
        return 0;

        case TCCMD_CAM_PPSSTANDBY:
        return 0;

        case TCCMD_CAM_PPSSELF:
        return 0;

        case TCCMD_CAM_SETGAIN:
        return 1;

        case TCCMD_CAM_SETFRAMECYCLE:
        return 4;

        case TCCMD_CAM_SETEXPOTIME:
        return 4;

        case TCCMD_CAM_CMOSNOFLIP:
        return 0;

        case TTCMD_CAM_CMOSFLIPHOR:
        return 0;

        case TCCMD_CAM_CMOSFLIPVER:
        return 0;

        case TCCMD_CAM_CMOSFLIPHAV:
        return 0;

        case TCCMD_CAM_GETSTATE:
        return 0;

        case TCCMD_CAM_VSTARTLINE:
        return 2;

        case TCCMD_CAM_SSTARTLINE:
        return 2;

        case TCCMD_CAM_SELECTBIT:
        return 1;

        case TCCMD_CAM_FPNEN:
        return 0;

        case TCCMD_CAM_FPNDIS:
        return 0;

        case TCCMD_CAM_SDPCEN:
        return 0;

        case TCCMD_CAM_SDPCDIS:
        return 0;

        case TCCMD_CAM_LOADFACSET:
        return 0;

        case TCCMD_CAM_LOADUSRSET:
        return 1;

        case TCCMD_CAM_SAVEUSRSET:
        return 1;

        case TCCMD_CAM_SETPROG:
        return 1;

        /* 小相机 */
        case TCCMD_CMOS_SNAP:
        return 0;

        case TCCMD_CMOS_SENDRECENT:
        return 0;

        case TCCMD_CMOS_RECENTMSG:
        return 0;

        case TCCMD_CMOS_SENDCAMARG:
        return 0;

        case TCCMD_CMOS_FORMATFLASH:
        return 0;

        case TCCMD_CMOS_ALLPHOTOSTA:
        return 0;

        case TCCMD_CMOS_DEFAULT:
        return 0;

        case TCCMD_CMOS_GETNOWARG:
        return 0;

        case TCCMD_CMOS_CONFIG:
        return 6;

        case TCCMD_CMOS_READPHOTO:
        return 12;

        case TCCMD_CMOS_PHOTOLENGTH:
        return 1;

        case TCCMD_CMOS_PHOTOARG:
        return 1;

        case TCCMD_CMOS_SAVE2SD:
        return 1;

        case TCCMD_CMOS_DELETEFILE:
        return 0;

        case TCCMD_CMOS_REINITFILE:
        return 0;

        /* 导航增强 */
        case TCCMD_NVE_POLL:
        return 0;

        case TCCMD_NVE_UP72:
        return 0;

        /* 存储板 */
        case TCCMD_STO_SETADDR:
        return 8;

        case TCCMD_STO_TRANSET:
        return 1;

        case TCCMD_STO_CLEARSATA:
        return 0;

        case TCCMD_STO_RESET:
        return 0;

        case TCCMD_STO_SATAON:
        return 0;

        case TCCMD_STO_SATAOFF:
        return 0;

        case TCCMD_STO_SETBAUD:
        return 1;

        case TCCMD_STO_TELECMD:
        return 13;

        case TCCMD_STO_GETSTATE:
        return 0;

        /* 数传 */
        case TCCMD_DT_CMD0BYTE:
        return 1;

        case TCCMD_DT_CMD1BYTE:
        return 2;

        case TCCMD_DT_CMD4BYTE:
        return 5;

        case TCCMD_DT_CMD8BYTE:
        return 9;

        case TCCMD_DT_CMD16BYTE:
        return 17;

        /* 测控 */
        case TCCMD_TMTC_RESET:
        return 0;

        case TCCMD_TMTC_GETSTATUS:
        return 0;

        case TCCMD_TMTC_SETFILE:
        return 1;

        case TCCMD_TMTC_DELETEFILE:
        return 1;

        case TCCMD_TMTC_SETNID:
        return 1;

        case TCCMD_TMTC_READBLOCK:
        return 8;

        case TCCMD_TMTC_FTPSTART:
        return 0;

        case TCCMD_TMTC_FTPSTOP:
        return 0;

        case TCCMD_TMTC_SETSEED:
        return 16;

        case TCCMD_TMTC_SETPACKCNT:
        return 2;

        case TCCMD_TMTC_SETFTPINV:
        return 1;

        case TCCMD_TMTC_ARGDOWNVIARF:
        return 0;

        case TCCMD_TMTC_TM30SON:
        return 0;

        case TCCMD_TMTC_TM30SOFF:
        return 0;

        case TCCMD_TMTC_FILEDOWNVIARF:
        return 8;

        /* 光电传感器 */
        case TCCMD_AMUR_SENDARG:
        return 0;

        case TCCMD_AMUR_TIME:
        return 0;

        case TCCMD_AMUR_PWRDOWN:
        return 0;

        case TCCMD_AMUR_SHOWTIME:
        return 0;

        case TCCMD_AMUR_GETTEMP:
        return 0;

        case TCCMD_AMUR_TEST:
        return 128;

        default:
        return -1;
    }
}
